package qimao.com.edu.entity;

import jakarta.persistence.*;
import java.time.LocalDateTime;
import java.util.Objects;

/**
 * 书架表
 * @author 86173
 *
 */
@Entity
@Table(name = "bookshelf")
public class Bookshelf {
	/**
	 * 书架表id
	 */
    @Id
    @Column(name = "bookshelf_id", nullable = false)
    private Long bookshelfId;
    
    /**
     * 用户ID
     */
    @JoinColumn(name = "user_id", nullable = false)
    private Integer userId;
    /**
     * 作品ID
     */
    @JoinColumn(name = "work_id", nullable = false)
    private Integer workId;
    /**
     * 记录上次读到多少章
     */
    @Column(name = "last_read_chapter_id")
    private Integer lastReadChapterId;
    /**
     * 上次阅读时间
     */
    @Column(name = "last_read_time")
    private LocalDateTime lastReadTime;
    /**
     * 加入书架的时间
     */
    @Column(name = "favorite_time", nullable = false)
    private LocalDateTime favoriteTime;
    /**
     * 是否收藏：0-否，1-是
     */
    @Column(name = "is_collect", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 0")
    private int isPinned;
    /**
     * 是否标星：0-否，1-是
     */
    @Column(name = "is_starred", nullable = false, columnDefinition = "TINYINT(1) DEFAULT 0")
    private int isStarred;
    
    // 无参构造方法
    public Bookshelf() {
    }

    // 有参构造方法
	public Bookshelf(Long bookshelfId, Integer userId, Integer workId, Integer lastReadChapterId,
			LocalDateTime lastReadTime, LocalDateTime favoriteTime, int isPinned, int isStarred) {
		super();
		this.bookshelfId = bookshelfId;
		this.userId = userId;
		this.workId = workId;
		this.lastReadChapterId = lastReadChapterId;
		this.lastReadTime = lastReadTime;
		this.favoriteTime = favoriteTime;
		this.isPinned = isPinned;
		this.isStarred = isStarred;
	}

	public Long getBookshelfId() {
		return bookshelfId;
	}

	public void setBookshelfId(Long bookshelfId) {
		this.bookshelfId = bookshelfId;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getWorkId() {
		return workId;
	}

	public void setWorkId(Integer workId) {
		this.workId = workId;
	}

	public Integer getLastReadChapterId() {
		return lastReadChapterId;
	}

	public void setLastReadChapterId(Integer lastReadChapterId) {
		this.lastReadChapterId = lastReadChapterId;
	}

	public LocalDateTime getLastReadTime() {
		return lastReadTime;
	}

	public void setLastReadTime(LocalDateTime lastReadTime) {
		this.lastReadTime = lastReadTime;
	}

	public LocalDateTime getFavoriteTime() {
		return favoriteTime;
	}

	public void setFavoriteTime(LocalDateTime favoriteTime) {
		this.favoriteTime = favoriteTime;
	}

	public int getIsPinned() {
		return isPinned;
	}

	public void setIsPinned(int isPinned) {
		this.isPinned = isPinned;
	}

	public int getIsStarred() {
		return isStarred;
	}

	public void setIsStarred(int isStarred) {
		this.isStarred = isStarred;
	}

	@Override
	public String toString() {
		return "Bookshelf [bookshelfId=" + bookshelfId + ", userId=" + userId + ", workId=" + workId
				+ ", lastReadChapterId=" + lastReadChapterId + ", lastReadTime=" + lastReadTime + ", favoriteTime="
				+ favoriteTime + ", isPinned=" + isPinned + ", isStarred=" + isStarred + "]";
	}
	
}
